package sv.gob.mh.dgii.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;


@Entity
@Table(name = "CD_HIST_DOCUMENTO", schema = "CTROLDOC")
@SequenceGenerator(name="SEQ_CD_HIST_DOCUMENTO" , sequenceName="SEQ_CD_HIST_DOCUMENTO")
public class CdHistDocumento implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4838631218684136089L;
	private Long nhistdocum;
	private CdDocumento ndocumento;
	private Date fhmodificacion;
	private String ninventario;
	private String dnumreferen;
	private String cusuariomodif;
	private TbUnidad tbUnidad;
	private Long ncantfolioinicial;
	private Long npieza;	
	private RcRuc rcRuc;
	private Long ncantfoliofinal;	
	private String naccion;
	

	public CdHistDocumento() {
	}

	public CdHistDocumento(Long nhistdocum,CdDocumento ndocumento,Date fhmodificacion,String ninventario,
			String dnumreferen,String cusuariomodif,TbUnidad tbunidad,Long ncantfolioinicial,Long npieza,
			RcRuc rcRuc,Long ncantfoliofinal,String naccion){
			this.nhistdocum = nhistdocum;
			this.ndocumento = ndocumento;
			this.fhmodificacion = fhmodificacion;
			this.ninventario = ninventario;
			this.dnumreferen = dnumreferen;
			this.cusuariomodif = cusuariomodif;
			this.tbUnidad = tbunidad;
			this.ncantfolioinicial = ncantfolioinicial;
			this.npieza = npieza;
			this.rcRuc = rcRuc;
			this.ncantfoliofinal = ncantfoliofinal;
			this.naccion = naccion;
		
	
	}

	@Id
	@Column(name = "N_HIST_DOCUM", unique = true, nullable = false, precision = 22, scale = 0)
	@GeneratedValue(strategy=GenerationType.AUTO, generator="SEQ_CD_HIST_DOCUMENTO")
	public Long getNhistdocum() {
		return this.nhistdocum;
	}

	public void setNhistdocum(Long nhistdocum) {
		this.nhistdocum = nhistdocum;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="N_DOCUMENTO")
	public CdDocumento getNdocumento() {
		return this.ndocumento;
	}

	public void setNdocumento(CdDocumento ndocumento) {
		this.ndocumento = ndocumento;
	}

	//@Temporal(TemporalType.DATE)
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "FH_MODIFICACION", nullable = false, length = 7)
	public Date getFhmodificacion() {
		return this.fhmodificacion;
	}

	public void setFhmodificacion(Date fhmodificacion) {
		this.fhmodificacion = fhmodificacion;
	}
	
	@Column(name = "N_INVENTARIO", length = 10)
	public String getNinventario() {
		return this.ninventario;
	}

	public void setNinventario(String ninventario) {
		this.ninventario = ninventario;
	}

	@Column(name = "D_NUM_REFEREN", length = 20)
	public String getDnumreferen() {
		return this.dnumreferen;
	}

	public void setDnumreferen(String dnumreferen) {
		this.dnumreferen = dnumreferen;
	}
	
	
	@Column(name = "C_USUARIO_MODIF", length = 30)
	public String getCusuariomodif() {
		return this.cusuariomodif;
	}

	public void setCusuariomodif(String cusuariomodif) {
		this.cusuariomodif = cusuariomodif;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "C_UNIDAD", nullable = false)
	public TbUnidad getTbUnidad() {
		return this.tbUnidad;
	}

	public void setTbUnidad(TbUnidad tbUnidad) {
		this.tbUnidad = tbUnidad;
	}
	
	
	@Column(name = "N_CANT_FOLIO_INICIAL" , precision = 10, scale = 0)
	public Long getNcantfolioinicial() {
		return this.ncantfolioinicial;
	}

	public void setNcantfolioinicial(Long ncantfolioinicial) {
		this.ncantfolioinicial = ncantfolioinicial;
	}
	
	
	@Column(name = "N_PIEZA" , precision = 5, scale = 0)
	public Long getNpieza(){
		return this.npieza;
	}

	public void setNpieza(Long npieza) {
		this.npieza = npieza;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "NIT_TECNICO")
	public RcRuc getRcRuc() {
		return this.rcRuc;
	}

	public void setRcRuc(RcRuc rcRuc) {
		this.rcRuc = rcRuc;
	}
	
	
	@Column(name = "N_CANT_FOLIO_FINAL" , precision = 10, scale = 0)
	public Long getNcantfoliofinal() {
		return this.ncantfoliofinal;
	}

	public void setNcantfoliofinal(Long ncantfoliofinal) {
		this.ncantfoliofinal = ncantfoliofinal;
	}
	
	@Column(name = "N_ACCION", length = 2)
	public String getNaccion() {
		return this.naccion;
	}

	public void setNaccion(String naccion) {
		this.naccion = naccion;
	}

}
